import { Component, OnInit } from '@angular/core';
import {HttpClient} from '@angular/common/http';
// import any = jasmine.any;

@Component({
  selector: 'app-goods',
  templateUrl: './goods.component.html',
  styleUrls: ['./goods.component.scss']
})
export class GoodsComponent implements OnInit {
public onkey: any = ''
public varieties: any[] = [
  // {
  //   png: '../../../assets/img/u1283.jpg',
  //   name: '苜蓿草',
  //   level: '特级',
  //   quality: '优质',
  //   trademark: '原生态苜蓿草',
  //   state: ' ',
  //   price: '18.00/t',
  //   OldPrice: '原价：20.00/t'
  // },
  // {
  //   png: '../../../assets/img/u1283.jpg',
  //   name: '苜蓿粉末(颗粒)',
  //   level: '特级',
  //   quality: '优质',
  //   trademark: '原生态苜蓿草',
  //   state: '粉末',
  //   price: '20.00/t',
  //   // OldPrice: ''
  // },
  // {
  //   png: '../../../assets/img/u1283.jpg',
  //   name: '苜蓿菜',
  //   level: '特级',
  //   quality: '优质',
  //   trademark: '原生态苜蓿菜',
  //   state: '',
  //   price: '20.00/t',
  //   // OldPrice: ''
  // }
]
  constructor(public http: HttpClient) { }
// 请求商品列表
  ngOnInit() {
    const pi = 'http://192.168.2.227:8080/goods/list';
    this.http.get(pi).subscribe((respnse: any) => {
      console.log(respnse.data.list);
      this.varieties = respnse.data.list;
      console.log(this.varieties);
    });
    // this.http.get('http://192.168.2.229:8080/sort/list').subscribe((respnse: any) => {
    //   console.log(respnse);
    //
    // });
    this.http.get('http://192.168.2.227:8080/sort/detail').subscribe((respnse: any) => {
      console.log(respnse);
    });
  }

}
